﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Query.aspx.cs" Inherits="Manage_Database_Query" %>
<html>
<head>
<!--#include file="../js/html_head.inc"-->
<link rel="stylesheet" href="../Themes/<%=ManageHelper.GetTheme()%>/style.css" type="text/css" />
</head>
<body>
<%=ds != null ? "<div class='msg_succeed'>查询成功，共返回<strong>" + ds.Tables[0].Rows.Count.ToString() + "</strong>条结果。</div>" : ""%>
<%=ManageHelper.PageErrMsg()!=""?"<div class='msg_failed'>"+ManageHelper.PageErrMsg()+"</div>":""%>

<form id="sqlForm" name="sqlForm" method="post" action="?act=query" onsubmit="return validator(this)">
<div class="mycolumn">
    <div class="columntitle">数据库查询</div>
    <table width="95%" align="center" cellpadding="3" cellspacing="3">
    <tr>
        <td align="left" width="150"><img src="../pic/icons/help.gif" alt="需要执行的数据库查询字符串，此字符串将对数据库进行查询操作，必须以“SELECT”字符串作为开头。" onclick="helpInf(this)"/> <nobr>数据库查询字符串：</nobr></td>
        <td align="left">
            <textarea style="width:300px;height:60px" class="colorblur" id="SqlStr" name="SqlStr" valid="required" errmsg="*需要执行的数据库查询字符串，此字符串将对数据库进行查询操作，必须以“SELECT”字符串作为开头。"><%=SqlStr %></textarea>
        </td>
    </tr>
    <tr>
        <td colspan="2" align="center" class="tdbutton" >
        <input type="submit" value="执 行" class="button" />
        </td>
    </tr>
    </table>
</div>
</form>

<% 
if (ds!=null)
{
%>
<div class="column">
    <div class="columntitle">数据库查询结果</div>
        <table cellspacing="0" cellpadding="0" rules="all" Align="center" border="0" style="border-width:0px;width:100%;border-collapse:collapse;">
	    <thead>
	    <tr class="summary-title" style="height: 25px" align="left">
		    <%
            for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
            {
            %>
		    <td><%=ds.Tables[0].Columns[i].ToString()%></td>
		    <%} %>
	    </tr>
	    </thead>
	    <tbody>
	    <%
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
        %>
        <tr class="tdbg" onmouseover="this.className='tdbg-dark';" onmouseout="this.className='tdbg';" style="height:25px;" align="left">
        <%
            for (int ii = 0; ii < ds.Tables[0].Columns.Count; ii++)
            {
            %>
		    <td><%=ds.Tables[0].Rows[i][ii].ToString() == "" ? "&nbsp;" : ds.Tables[0].Rows[i][ii].ToString()%></td>
		    <%} %>
		</tr>
        <%} %>
	    </tbody>
	</table>
</div>
<%} %>

</body>
</html>
